//
//  LMLocalNetworkManager.h
//  LMDevelopmentTool
//
//  Created by LaiMing on 2021/12/1.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN


#pragma mark - LMLocalNetworkManagerDelegate
@class LMLocalNetworkManager;

@protocol LMLocalNetworkManagerDelegate <NSObject>

@optional

/// 发送数据包事件回调
/// @param manager 管理者
/// @param packet 数据包
/// @param sequenceNumber 调用次数
- (void)pingManager:(LMLocalNetworkManager *)manager didSendPacket:(NSData *)packet sequenceNumber:(uint16_t) sequenceNumber;


/// 发送失败事件回调
/// @param manager 管理者
/// @param packet 数据包
/// @param sequenceNumber 调用次数
/// @param error 错误  ( error.code == 65 , no route to host )
- (void)pingManager:(LMLocalNetworkManager *)manager didFailToSendPacket:(NSData *)packet sequenceNumber:(uint16_t)sequenceNumber error:(NSError *)error;

@end



#pragma mark - LMLocalNetworkManager
@interface LMLocalNetworkManager : NSObject

/// 代理
@property (nonatomic, weak) id<LMLocalNetworkManagerDelegate> delegate;

/// 发送数据包间隔时间  默认2秒
@property (nonatomic, assign) float intervalTime;

/// 数据包最大发送次数,超过次数后停止发送。设置为0，则不停止。 默认10次
@property (nonatomic, assign) NSUInteger sendDataPacketMaxCount;


/// 单例创建
+ (instancetype _Nonnull)shared;

/// 销毁单例
+ (void)destory;

/// 唤醒本地网络权限
-(void)wakeUpLocalNetworkPermissions;


@end

NS_ASSUME_NONNULL_END
